import React, { Component } from 'react';
import './style.css'
// 使用组件方式
import ReactEcharts from 'echarts-for-react';
import 'echarts-wordcloud'
import request from '../../request';

interface CourseItem {
  index?: number;
  name?: string;
  url?: string | undefined;
  num?: string;
  price?: number;
  chg?: number;
}

interface DataStructure {
  [key: string]: CourseItem[];
}

interface State {
  loading: boolean;
  isLogin: boolean;
  data: DataStructure;
}

class Word extends Component{
  state:State = {
    loading: true,
    isLogin: true,
    data: {}
  }
  componentDidMount() {
    request.get('/api/isLogin').then(res => {
      const data: boolean = res.data;
      if (!data) {
        this.setState({
          isLogin: false,
          loading: false
        });
      } else {
        this.setState({
          loading: false
        });
      }
    });
    request.get('/api/showWenCaiYg').then(res => {
      const data = res.data;
      if (data) {
        this.setState({ data });
      }
    });

  }

  getOption: () => echarts.EChartOption = () => {
    // const { data } = this.state;
    return {}
  };

  render() {
    return (
      <div className="word-wraper">
        <div className="word-wrapper-word">
          <ReactEcharts option={this.getOption()} />
        </div>
      </div>
    )
  }
}

export default Word
